{% extends "ITInfluence/base.html" %}

{% block page %}

<h3>Twitter collection manager</h3>

<p>
Streaming: 
{% if isStreaming %}
<a title="Stop streaming" href="/twitter/stopStreaming/">{{ isStreaming }}</a>
({{streamingHashtag}})
{% else %}
{{ isStreaming }}
{% endif %}
</p>

<h4>Collect tweets</h4>

{% if not isStreaming %}
<form method="post" action="">
<table id="collect-form-table">
<tr>
<td>
<label for="hashtag">Hashtag:</label>
</td>
<td>
<input type="text" name="hashtag" autofocus="autofocus" title="You can insert multiple hashtags, seperated by commas." placeholder="tag1,tag2,tag3" />
</td>
<td>
<span style="font-size: 12px; color: blue">Do not add a leading #, we know it's a hashtag.</span>
</td>
</tr>
<tr>
<td>
<label for="stopTweetCount">Max tweets to collect (0 for unlimited):</label>
</td>
<td>
<input type="text" name="stopTweetCount" value="5000" title="We'll stop collecting tweets as soon as we have collected this many for this session." />
</td>
<td></td>
</tr>
<tr>
<td>
<label for="stopTime">Max minutes to collect for (0 for unlimited):</label>
</td>
<td>
<input type="text" name="stopTime" value="0" title="We'll stop collecting tweets after this many minutes." />
</td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Start collecting tweets" value="0" />
</td>
</tr>
</table>
{% csrf_token %}

</form>
{% else %}
Tweet collection in progress...
{% endif %}

<h4>Collect followers</h4>

{% if not isCollectingFollowers %}
<p>
This operation can take a very long time since the Twitter API is rate limited to 15 calls every 15 minutes. Here is an estimation of the time needed to collect the followers for all the authors of the previously collected tweets:<br />
<strong>Estimated time to collect followers</strong>: {{ followersTimeDays }} days = {{ followersTimeHours }} hours = {{ followersTimeMinutes }} minutes
</p>
{% else %}
<strong>Remaining time to collect followers</strong>: {{ followersRemainingTimeDays }} days = {{ followersRemainingTimeHours }} hours = {{ followersRemainingTimeMinutes }} minutes
{% endif %}

<p>
Already collected followers: {{ followersProgressPercentage }}%
</p>


<p>
Collecting followers:
<a href="/twitter/collect/toggleFollowersCollection/" title="{% if isCollectingFollowers %}Stop collecting{% else %}Start collecting{% endif %}">{{isCollectingFollowers}}</a>
</p>


{% endblock page %}